import { Size, Vec2, v2 } from "cc";
import { GlobalConfig } from "../Config/GlobalConfig";
import { size } from "cc";
import { GlobalEnum } from "../Config/GlobalEnum";

export class StorageTemp {
    userSetting: UserSetting;
    userAssets: UserAsstes;
    levelAssets: LevelAssets;
    constructor() {
        this.userSetting = new UserSetting();
        this.userAssets = new UserAsstes();
        this.levelAssets = new LevelAssets();
    }
}
// 玩家的信息
export class SelfInfo {
    nickName: string = null;
    avatarUrl: string = null;
    gender: string = null;
    city: string = null;
    // 是否已经授权
    isAuthorize: boolean = false;
}

/**玩家的设置 */
export class UserSetting {
    // 音频开关
    AudioSwith = true;
    // 震动开关
    ShakeSwith = true;
    //显示隐私政策-一次
    showPrivacy = true;
    // bgm
    BgmSwith = true;
}

//玩家的关卡数据记录
export class LevelAssets {
    curLv = 1;
    maxLv = 1;
    guideLv = 1;
    data: LevelDataTmp = new LevelDataTmp();
    //记录 普通模式随机关卡 -1表示没有随机ID
    randLv = -1;
    // 记录 普通模式上一次随机关卡
    preRandLv = -1;
    // 记录 困难模式关卡
    hardLv = 1;
    // 记录 困难模式随机关卡 -1表示没有随机ID
    hardRandLv = -1;
    // 随机的关卡数据
    randLvData: LevelDataTmp = null;
}

//玩家获取的资源数据
export class UserAsstes {
    //表示金币/钱 等数据
    asset = GlobalConfig.Award.InitialGold;
    energy = GlobalConfig.Award.InitialEnergy;

    //皮肤数据
    skin = {
        choose: 0,
        unlock: [0],
    };
    //抽免费奖次数
    turntableNum = 1;

    //签到记录
    signData = { lastTime: 0, count: -1, dayIdx: 0, prePopTime: 0 };

    //体力恢复时间
    lastRecoverTime = Date.now();

    //
    // 解锁进度-记录关卡数量
    unlockLvRec = {
        skin: 0,        //皮肤按照顺序给
        tip: 0
    }

    // 是否是第一次进入游戏
    isFirstEnter = true;

    // 补给视频观看进度
    supplyRecord = {
        gold: 0,
        energy: 0
    }

    // 礼包领取时间
    lastGiftTime = 0;

    // 本地排行信息-new
    // 国家排行信息
    nationRankData: { [uid: string]: RankData } = {};
    // 地区排行信息
    reigionRankData: { [uid: string]: RankData } = {};


    // 每日信息
    dayInfo: { [key: string]: any } = {
        // tt 侧边栏导航
        navigateToScene: { isFinish: false, lastTime: 0 },
    };

    // 碎片收集数量
    chipNum = 0;
    // 章节碎片解锁
    chapterChipUnlock: { [key: number]: { idx: number, isFinish: boolean } } = {
        1: { idx: 5, isFinish: true },
        2: null,
        3: null,
        4: null,
    };

    enterGameCount = 0;

    //关卡进入统计
    lvEnterCount: { [key: number]: number } = {
    }
    //关卡失败统计
    lvFailCount: { [key: number]: number } = {
    }
    //大礼包弹出时间
    autoPopGiftTime = 0;

    /** 每日任务 */
    missionPreRefreshTime = 0;
    missionRecs: { [key: number]: MissionData } = {
    };
    /** 每周任务 */
    missionWeekPreRefreshTime = 0;
    missionWeekRecs: { [key: number]: MissionData } = {
    };

    /** 转盘抽奖次数 - 每6次获得额外奖励*/
    turntableRecordCount = 0;

    // 道具信息
    propCountRecs: { [key: number]: number } = {
        [GlobalEnum.PropType.Remove]: 1,
        [GlobalEnum.PropType.RefreshColor]: 1,
        [GlobalEnum.PropType.RefreshRoles]: 1
    }
    // 一次性提示信息记录
    onceTipInfo: { [key: number]: number } = {
    }

    // 每日免费关卡次数
    daliyFreeLvCount = GlobalConfig.DaliyFreeLvCount;
    daliyFreeLvRefreshTime = 0;

}
// 每日任务数据
export class MissionData {
    idx = '0';
    isFinish = false;
    count = 0;
    isAward = false;
}

// 排行数据
export class RankData {
    uid: string;
    name: string;
    iconIdx: string;
    lv: number;
    // 虚拟排行参数
    updateTime: number;
    updateCD: number;
    addLv: number;
}

//详细的关卡数据-根据游戏变化
export class LevelDataTmp {
    lv: number = 1;
    gridSize: Size = size();
    mapSize: Size = size();
    cldArr: { name: string, angle: number, formatSize: Size, formatPos: Vec2, direc: Vec2 }[] = [];
    animArr: { name: string, angle: number, formatSize: Size, formatPos: Vec2, direc: Vec2 }[] = [];

}
